<%--
  Created by IntelliJ IDEA.
  User: zhuya
  Date: 2016/2/3
  Time: 13:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="privilege" uri="/WEB-INF/privilege.tld" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <title>办件详情</title>
  <link rel="stylesheet" href="<c:url value='/resource/wechat/css/frozen.css'/>">
  <link rel="stylesheet" type="text/css" href="<c:url value='/resource/wechat/css/main.css'/>" />
  <script src="<c:url value='/resource/js/jquery-2.0.min.js'/>"></script>
  <script src="<c:url value='/resource/js/jquery.form.min.js'/>"></script>
  <script src="<c:url value='/resource/wechat/js/zepto.min.js'/>"></script>
  <script src="<c:url value='/resource/wechat/js/frozen.js'/>"></script>

</head>
<body class="bg_fff" ontouchstart>
<section class="ui-container">
  <ul class="ul_lost">
  </ul>
  <input type="hidden" id="prjguid" value="${prjguid}">
  <input type="hidden" id="loginId" value="${loginId}">
  <input type="hidden" id="userName" value="${userName}">
  <%--<h3 class="wdbj_tit">满意度评价</h3>--%>
  <%--<ul class="ui-justify-flex ui-whitespace">--%>
    <%--<li class="test-img"> <label class="ui-radio" for="radio">--%>
      <%--<input type="radio" name="radio" checked="checked">--%>
    <%--</label> <span class="text_grey">非常满意</span></li>--%>
    <%--<li class="test-img"> <label class="ui-radio" for="radio">--%>
      <%--<input type="radio" name="radio">--%>
    <%--</label><span class="text_grey">基本满意</span></li>--%>
    <%--<li class="test-img"> <label class="ui-radio" for="radio">--%>
      <%--<input type="radio" name="radio">--%>
    <%--</label><span class="text_grey">不满意</span></li>--%>

  <%--</ul>--%>
  <%--<h3 class="wdbj_tit">评价意见</h3>--%>
  <%--<div class="ywzx_textarea">--%>
    <%--<textarea placeholder="请输入您的咨询问题，我们会尽快解答您！"></textarea>--%>
  <%--</div>--%>
  <%--<div class="ui-btn-wrap">--%>
    <%--<button class="ui-btn-lg ui-btn-primary">--%>
      <%--提交评价--%>
    <%--</button>--%>
  <%--</div>--%>
</section>
</body>

<script>

  $(function(){

    $.ajax({
      type : "get",
      url : "<c:url value='/api/project/info/'/>" + $("#prjguid").val(),
      dataType : "json",
      async : false,
      success : function(resp){
        if(resp&&resp.succ){
          var _data = resp.data;
          var _projectBillid = _data.tskNum==null?"":_data.tskNum;
          var dueDays = _data.dueDays==null?"":_data.dueDays;
          var _caseName = _data.matName==null?"":_data.matName;
          var startDoTime = _data.startDoDateStr==null?"":_data.startDoDateStr;
          var deptName = _data.deptName==null?"":_data.deptName;
          var projectStatus_cn = _data.projectStatusCn==null?"":_data.projectStatusCn;
          var dataSouceType = _data.dataSouceType;
          var _html = "<li><div class='lf80'>办件编号：</div><div class='rt_80'>"+ _projectBillid +"</div></li>"
                  +"<li><div class='lf80'>事项名称：</div><div class='rt_80'>" + _caseName + "</div></li>"
                  +"<li><div class='lf80'>办件状态：</div><div class='rt_80'>" + projectStatus_cn+ "</div></li>"
                  +"<li><div class='lf80'>承诺天数：</div><div class='rt_80'>" + dueDays+ "天</div></li>"
                  +"<li><div class='lf80'>申报时间：</div><div class='rt_80'>" + startDoTime + "</div></li>"
                  +"<li><div class='lf80'>处理部门：</div><div class='rt_80'>" + deptName + "</div></li>";
          $(".ul_lost").html(_html);
          var _dfHtml = "";
          if(_data.projectStatus == "1"){
            if(dataSouceType == 1){
              _dfHtml = "<div class='ui-btn-wrap' style='clear: left'><button id='chexiao' class='ui-btn-lg ui-btn-primary'>撤销</button></div>";
            }else {
              _dfHtml = "";
            }
          }else if(_data.projectStatus == "2" ||_data.projectStatus == "3"){
            _dfHtml = "";
          }else if(_data.projectStatus == "9"){
            if(_data.evaluationContent == null || _data.evaluationContent == ""){
              _dfHtml = "<h3 class='wdbj_tit'>满意度评价：</h3><ul class='ui-justify-flex ui-whitespace'>" +
                      "<li class='test-img'><label class='ui-radio' for='radio'><input value='0' type='radio' name='radio' checked='checked'>" +
                      "</label><span class='text_grey'>满意</span></li><li class='test-img'><label class='ui-radio' for='radio'>" +
                      "<input value='1' type='radio' name='radio'></label><span class='text_grey'>基本满意</span></li><li class='test-img'><label class='ui-radio' for='radio'>" +
                      "<input value='2' type='radio' name='radio'></label><span class='text_grey'>不满意</span></li></ul><h3 class='wdbj_tit'>评价意见：</h3>" +
                      "<div class='ywzx_textarea'><textarea id='pjnr' placeholder='请输入评价内容！' maxlength='100'></textarea></div><div class='ui-btn-wrap'>" +
                      "<button class='ui-btn-lg ui-btn-primary' id='pingjia'>提交评价</button></div>";
            }else {
              _dfHtml = "<h3 class='wdbj_tit'>满意度评价：</h3><ul class='ui-justify-flex ui-whitespace'>" +
                      "<li class='test-img'><label class='ui-radio' for='radio'><input disabled value='0' type='radio' name='radio' checked='checked'>" +
                      "</label><span class='text_grey'>满意</span></li><li class='test-img'><label class='ui-radio' for='radio'>" +
                      "<input disabled value='1' type='radio' name='radio'></label><span class='text_grey'>基本满意</span></li><li class='test-img'><label class='ui-radio' for='radio'>" +
                      "<input disabled value='2' type='radio' name='radio'></label><span class='text_grey'>不满意</span></li></ul><h3 class='wdbj_tit'>评价意见：</h3>" +
                      "<div class='ywzx_textarea'><textarea readonly id='pjnr' placeholder='请输入评价内容！'>"+ _data.evaluationContent +"</textarea></div><div class='ui-btn-wrap'>";
              $("input[type='radio']").each(function(){
                if(this.value == _data.evaluationGrade){
                  this.checked = true;
                }
              })
            }
          }else if(_data.projectState == "13"){
            _dfHtml = "<h3 class='wdbj_tit'>回复意见：</h3><div class='ywzx_textarea'>" +
                    "<textarea readonly>"+ _data.checkIdea +"</textarea></div>";
          }
          $(".ui-container").append(_dfHtml);
        }else {
          $(".ui-container").append("<div style='text-align: center;height: 50px; line-height: 50px;'>未查询到结果</div>");
        }
      }
    });

    $("#chexiao").click(function(){
      $.ajax({
        url : "<c:url value='/api/project/undo/'/>" + $("#prjguid").val(),
        type : "get",
        dataType : "json",
        async : false,
        success : function(resp){
          if(resp&&resp.succ){
            alert(resp.msg);
            window.location.href = "<c:url value='/weixin/transact/index'/>";
          }else {
            alert(resp.msg);
          }
        }
      });
    })

    $("#pingjia").click(function(){
      if($("#pjnr").val() == ""){
        alert("请输入评价内容");
        return;
      }
      var grade;
      $("input[type='radio']").each(function(){
        if(this.checked == true){
          grade = this.value;
        }
      })
      $.ajax({
        type : "post",
        data : '{"evaluationGrade":"' + grade + '","createUserName":"' + $("#userName").val() + '","evaluationContent":"' + $("#pjnr").val() + '","createUserId":"' + $("#loginId").val() + '","evaluaTionType":"2","prjGuid":"' + $("#prjguid").val() + '"}',
        url : "<c:url value='/api/matters/product/myd'/>",
        dataType : "json",
        contentType : "application/json;charset=utf-8",
        success : function(resp){
          if(resp&&resp.succ){
            alert(resp.msg);
            window.location.href = "<c:url value='/weixin/transact/index'/>";
          }else {
            alert(resp.msg);
          }
        }
      });
    });


  });

  function changeState(state){
    if(state == "提交"){
      return "待预审";
    }else if(state == "处理中"){
      return "办理中";
    }
    return state;
  }


</script>

</html>